home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / MoreFiles 1.2.1 / MoreDesktopMgr.p < prev    next >
Encoding:
Text File  |  1994-07-22  |  9.6 KB  |  241 lines  |  [TEXT/PJMM]

  1. UNIT MoreDesktopMgr;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    A collection of useful high-level Desktop Manager routines.                }
  6. {    If the Desktop Manager isn't available, use the Desktop file            }
  7. {    for 'read' operations.                                                    }
  8. {                                                                            }
  9. {    We do more because we can...                                            }
  10. {                                                                            }
  11. {    by Jim Luther and Nitin Ganatra, Apple Developer Technical Support        }
  12. {                                                                            }
  13. {    by Jim Luther, Apple Developer Technical Support                        }
  14. {                                                                            }
  15. {    File:        MoreDesktopMgr.p                                            }
  16. {                                                                            }
  17. {    Copyright © 1992-1994 Apple Computer, Inc.                                }
  18. {    All rights reserved.                                                    }
  19. {                                                                            }
  20. {    You may incorporate this sample code into your applications without        }
  21. {    restriction, though the sample code has been provided "AS IS" and the    }
  22. {    responsibility for its operation is 100% yours.  However, what you are    }
  23. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  24. {    after having made changes. If you're going to re-distribute the source,    }
  25. {    we require that you make it clear in the source that the code was        }
  26. {    descended from Apple Sample Code, but that you've made changes.            }
  27.  
  28.  
  29. INTERFACE
  30.  
  31.  
  32. {***************************************************************************}
  33.  
  34.  
  35.     FUNCTION DTOpen (volName: StringPtr;
  36.                                     vRefNum: Integer;
  37.                                     VAR dtRefNum: Integer;
  38.                                     VAR newDTDatabase: Boolean): OSErr;
  39. {    The DTOpen function opens a volume's desktop database. It returns        }
  40. {    the reference number of the desktop database and indicates if the        }
  41. {    desktop database was created as a result of this call (if it was        }
  42. {    created, then it is empty).                                                }
  43. {                                                                            }
  44. {    volName            input:    A pointer to the name of a mounted volume        }
  45. {                            or nil.                                            }
  46. {    vRefNum            input:    Volume specification.                            }
  47. {    dtRefNum        output:    The reference number of Desktop Manager's        }
  48. {                            desktop database on the specified volume.        }
  49. {    newDTDatabase    output:    true if the desktop database was created as a    }
  50. {                            result of this call and thus empty.                }
  51. {                            false if the desktop database was already        }
  52. {                            created, or if it could not be determined if it    }
  53. {                            was already created.                            }
  54.  
  55.  
  56. {***************************************************************************}
  57.  
  58.  
  59.     FUNCTION DTGetAPPL (volName: StringPtr;
  60.                                     vRefNum: Integer;
  61.                                     creator: OSType;
  62.                                     VAR applVRefNum: Integer;
  63.                                     VAR applParID: LongInt;
  64.                                     VAR applName: Str255): OSErr;
  65. {    The DTGetAPPL function finds an application (file type 'APPL') with        }
  66. {    the specified creator on the specified volume. It first tries to get    }
  67. {    the application mapping from the desktop database. If that fails, then    }
  68. {    it tries to find an application with the specified creator using        }
  69. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  70. {    find an application in the Desktop file.                                }
  71. {                                                                            }
  72. {    volName        input:    A pointer to the name of a mounted volume            }
  73. {                        or nil.                                                }
  74. {    vRefNum        input:    Volume specification.                                }
  75. {    creator        input:    The file's creator type.                            }
  76. {    applVRefNum    output:    The volume reference number of the volume the        }
  77. {                        application is on.                                    }
  78. {    applParID    output:    The parent directory ID of the application.            }
  79. {    applName    output:    The name of the application.                        }
  80.  
  81.  
  82. {***************************************************************************}
  83.  
  84.  
  85.     FUNCTION FSpDTGetAPPL (volName: StringPtr;
  86.                                     vRefNum: Integer;
  87.                                     creator: OSType;
  88.                                     VAR spec: FSSpec): OSErr;
  89. {    The FSpDTGetAPPL function finds an application (file type 'APPL') with    }
  90. {    the specified creator on the specified volume. It first tries to get    }
  91. {    the application mapping from the desktop database. If that fails, then    }
  92. {    it tries to find an application with the specified creator using        }
  93. {    the File Manager's CatSearch routine. If that fails, then it tries to    }
  94. {    find an application in the Desktop file.                                }
  95. {                                                                            }
  96. {    volName        input:    A pointer to the name of a mounted volume            }
  97. {                        or nil.                                                }
  98. {    vRefNum        input:    Volume specification.                                }
  99. {    creator        input:    The file's creator type.                            }
  100. {    spec        output:    FSSpec record containing the application name and    }
  101. {                        location.                                            }
  102.  
  103.  
  104. {***************************************************************************}
  105.  
  106.  
  107.     FUNCTION DTGetIcon (volName: StringPtr;
  108.                                     vRefNum: Integer;
  109.                                     iconType: Integer;
  110.                                     fileCreator: OSType;
  111.                                     fileType: OSType;
  112.                                     VAR iconHandle: Handle): OSErr;
  113. {    The DTGetIcon function retrieves the specified icon and returns it in    }
  114. {    a newly created handle. The icon is retrieves from the Desktop Manager    }
  115. {    or if the Desktop Manager is not available, from the Finder's Desktop    }
  116. {    file. Your program is responsible for disposing of the handle when it    }
  117. {    is done using the icon.                                                    }
  118. {                                                                            }
  119. {    volName        input:    A pointer to the name of a mounted volume            }
  120. {                        or nil.                                                }
  121. {    vRefNum        input:    Volume specification.                                }
  122. {    iconType    input:    The icon type as defined in Files.h. Valid values    }
  123. {                        are:                                                }
  124. {                            kLargeIcon                                        }
  125. {                            kLarge4BitIcon                                    }
  126. {                            kLarge8BitIcon                                    }
  127. {                            kSmallIcon                                        }
  128. {                            kSmall4BitIcon                                    }
  129. {                            kSmall8BitIcon                                    }
  130. {    fileCreator    input:    The icon's creator type.                            }
  131. {    fileType    input:    The icon's file type.                                }
  132. {    iconHandle    output:    A Handle containing the newly created icon.            }
  133.  
  134.  
  135. {***************************************************************************}
  136.  
  137.  
  138.     FUNCTION DTSetComment (vRefNum: Integer;
  139.                                     dirID: LongInt;
  140.                                     name: StringPtr;
  141.                                     comment: Str255): OSErr;
  142. {    The DTSetComment function sets a file or directory's Finder comment        }
  143. {    field. The volume must support the Desktop Manager because you only        }
  144. {    have read access to the Desktop file.                                    }
  145. {                                                                            }
  146. {    vRefNum    input:    Volume specification.                                    }
  147. {    dirID    input:    Directory ID.                                            }
  148. {    name    input:    Pointer to object name, or nil when dirID                }
  149. {                    specifies a directory that's the object.                }
  150. {    comment    input:    The comment to add. Comments are limited to 200            }
  151. {                    characters; longer comments are truncated.                }
  152.  
  153.  
  154. {***************************************************************************}
  155.  
  156.  
  157.     FUNCTION FSpDTSetComment (spec: FSSpec;
  158.                                     comment: Str255): OSErr;
  159. {    The FSpDTSetComment function sets a file or directory's Finder comment    }
  160. {    field. The volume must support the Desktop Manager because you only        }
  161. {    have read access to the Desktop file.                                    }
  162. {                                                                            }
  163. {    spec    input:    An FSSpec record specifying the file or directory.        }
  164. {    comment    input:    The comment to add. Comments are limited to 200            }
  165. {                    characters; longer comments are truncated.                }
  166.  
  167.  
  168. {***************************************************************************}
  169.  
  170.  
  171.     FUNCTION DTGetComment (vRefNum: Integer;
  172.                                     dirID: LongInt;
  173.                                     name: StringPtr;
  174.                                     VAR comment: Str255): OSErr;
  175. {    The DTGetComment function gets a file or directory's Finder comment        }
  176. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  177. {    not available, from the Finder's Desktop file.                            }
  178. {                                                                            }
  179. {    vRefNum    input:    Volume specification.                                    }
  180. {    dirID    input:    Directory ID.                                            }
  181. {    name    input:    Pointer to object name, or nil when dirID                }
  182. {                    specifies a directory that's the object.                }
  183. {    comment    output:    A Str255 where the comment is to be returned.            }
  184.  
  185.  
  186. {***************************************************************************}
  187.  
  188.  
  189.     FUNCTION FSpDTGetComment (spec: FSSpec;
  190.                                     VAR comment: Str255): OSErr;
  191. {    The FSpDTGetComment function gets a file or directory's Finder comment    }
  192. {    field (if any) from the Desktop Manager or if the Desktop Manager is    }
  193. {    not available, from the Finder's Desktop file.                            }
  194. {                                                                            }
  195. {    spec    input:    An FSSpec record specifying the file or directory.        }
  196. {    comment    output:    A Str255 where the comment is to be returned.            }
  197.  
  198.  
  199. {***************************************************************************}
  200.  
  201.  
  202.     FUNCTION DTCopyComment (srcVRefNum: Integer;
  203.                                     srcDirID: LongInt;
  204.                                     srcName: StringPtr;
  205.                                     dstVRefNum: Integer;
  206.                                     dstDirID: LongInt;
  207.                                     dstName: StringPtr): OSErr;
  208. {    The DTCopyComment function copies the file or folder comment from the    }
  209. {    source to the destination object.  The destination volume must support    }
  210. {    the Desktop Manager because you only have read access to the Desktop    }
  211. {    file.                                                                    }
  212. {                                                                            }
  213. {    srcVRefNum    input:    Source volume specification.                        }
  214. {    srcDirID    input:    Source directory ID.                                }
  215. {    srcName        input:    Pointer to source object name, or nil when srcDirID    }
  216. {                        specifies a directory that's the object.            }
  217. {    dstVRefNum    input:    Destination volume specification.                    }
  218. {    dstDirID    input:    Destination directory ID.                            }
  219. {    dstName        input:    Pointer to destination object name, or nil when        }
  220. {                        dstDirID specifies a directory that's the object.    }
  221.  
  222.  
  223. {***************************************************************************}
  224.  
  225.  
  226.     FUNCTION FSpDTCopyComment (srcSpec: FSSpec;
  227.                                     dstSpec: FSSpec): OSErr;
  228. {    The FSpDTCopyComment function copies the desktop database comment from    }
  229. {    the source to the destination object.  Both the source and the            }
  230. {    destination volumes must support the Desktop Manager.                    }
  231. {                                                                            }
  232. {    srcSpec        input:    An FSSpec record specifying the source object.        }
  233. {    dstSpec        input:    An FSSpec record specifying the destination object.    }
  234.  
  235.  
  236. {***************************************************************************}
  237.  
  238.  
  239. IMPLEMENTATION
  240.  
  241. END.